/*!
\file AlgWarshall.cpp
\brief Contains implementation of Warshall's Algorithm.
\ingroup Plugins
*/

#include"AlgWarshall.h" 

AlgWarshall::AlgWarshall( Graph *g ): Algorithm( g ){
	
}

AlgWarshall::~AlgWarshall(){
	
}

void AlgWarshall::run(){
	for( int i = 0; i < graph()->numNodes(); i++ ){
		for( int j = 0; j < graph()->numNodes(); j++ ){
			for( int k = 0; k < graph()->numNodes(); k++ ){
				//If no path from j to k
				if( (*graph())[j][k] < 0 ){
					//If path j--i and i--k exist
					if( (*graph())[j][i] >= 0 && (*graph())[i][k] >= 0 ){
						graph()->createEdge(graph()->node(j), graph()->node(k));
						highlight( graph()->edge(graph()->numEdges()-1) );
					}
				}
			}
		}
	}
}

